Bash tweak of the day:
find . -name "*.png" -exec xxd -i "{}" "{}.h" ";"
Thanks to CC for the assist on basic bash-fu.
Bash tweak of the day:
find . -name "*.png" -exec xxd -i "{}" "{}.h" ";"
Thanks to CC for the assist on basic bash-fu.
For char literals, use single quotes:
if (testChar == 'A') NSLog(@"It's an A");Or represent the character using the code point number:
if (testChar == 0x1e01) NSLog(@"It's an A with a ring below");The compiler sees double-quotes as a string, so builds "A" as equivalent to a
const char *
(which gives you there error message about the pointer).
Working on cleaning the warnings out of our iPhone app - stuff like this matters. A little.
“Why do you use Internet Explorer? Do you know that there are other options for browsers?”, I asked.
“No, not really. As far as I’m concerned, when I access the internet, I just need to click on the big blue ‘e’ and do a search. I don’t know why I would use anything else.”
“What does the ‘e’ stand for, Alex?”
“The ‘e’ stands for ‘internet’”, he replied.
I think it's difficult for technical people to understand just how complicated computers really are, since we live in them all the time.
Bam.UIViewController *mainViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
if([mainViewController isKindOfClass:[UITabBarController class]]){
UIViewController *modalViewController = [mainViewController modalViewController];
if(modalViewController && (id)modalViewController != [NSNull null])
[mainViewController dismissModalViewControllerAnimated:NO];
}
NSLog(@"%@",[NSThread callStackSymbols]);
Should probably put this in TextExpander or something.
I realized I was trying to position the start and end point using the layer coordinate system, instead I should use relative values between 0.0 and 1.0.gradient.startPoint = CGPointMake(0, 0.5);
gradient.endPoint = CGPointMake(1.0, 0.5);Like this it works.
Thanks for the response.
Gradients having a separate coordinate system makes total sense, but somehow always throws me.
#define elipses @"..." - (NSString*)stringByTruncatingToWidth:(CGFloat)width withFont:(UIFont *)font{ NSMutableString *truncatedString = [[self mutableCopy] autorelease]; if ([self sizeWithFont:font].width > width) { width -= [ellipsis sizeWithFont:font].width; NSRange range = {truncatedString.length - 1, 1}; while ([truncatedString sizeWithFont:font].width > width) { [truncatedString deleteCharactersInRange:range]; range.location--; } [truncatedString replaceCharactersInRange:range withString:ellipsis]; } return truncatedString; }
Pretty darn useful anywhere you're overriding drawRect and don't feel like wrecking your designer's font settings.
void Swizzle(Class c, SEL orig, SEL new){ Method origMethod = class_getInstanceMethod(c, orig); Method newMethod = class_getInstanceMethod(c, new); if(class_addMethod(c, orig, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) class_replaceMethod(c, new, method_getImplementation(origMethod), method_getTypeEncoding(origMethod)); else method_exchangeImplementations(origMethod, newMethod); }
How to Swizzle, the awesome way. Using a method like this allows similar functionality to Rails' alias_method_chain, allowing you to extend core system methods on-the-fly even though Apple doesn't tell you what those methods do. This is a powerful technique for extending functionality, and hooking in to tightly coupled classes like UINavigationController and UINavigationBar.
I know there are people that think back to the ‘good old days’, but for me the good old days are right now. I am more excited about what I’m doing and what I’m working on than ever before.
This guy is one of my personal heroes.
So, today I found out UITableView lacks a ScrollToBottom method, despite having a ScrollToTop method. Seriously Apple? What the hell? I guess I never really felt like a library was half-assed like that when I was working with Ruby stuff. Anyway, here's an easy ScrollToBottom method. Put it in a category on UIScrollView for maximum effect.
#import "UIScrollView+Helpers.h" @implementation UIScrollView (UIScrollView_Helpers) -(void) scrollToBottom:(BOOL)animated{ CGSize content = [self contentSize]; CGRect bottom = CGRectMake(0, content.height - self.frame.size.height, self.frame.size.width, self.frame.size.height); [self scrollRectToVisible:bottom animated:animated]; } @end